home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / edit.php < prev    next >
Encoding:
PHP Script  |  2005-04-20  |  8.1 KB  |  302 lines

  1. <?php
  2. require_once('admin.php');
  3.  
  4. $title = __('Posts');
  5. $parent_file = 'edit.php';
  6. require_once('admin-header.php');
  7.  
  8. $_GET['m'] = (int) $_GET['m'];
  9.  
  10. get_currentuserinfo();
  11.  
  12. $drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID");
  13. if (1 < $user_level) {
  14.     $editable = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_level <= '$user_level' AND ID != $user_ID");
  15.     if( is_array( $editable ) == false )
  16.             $other_drafts = '';
  17.     else {
  18.         $editable = join(',', $editable);
  19.         $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) ");
  20.     }
  21. } else {
  22.     $other_drafts = false;
  23. }
  24.  
  25. if ($drafts || $other_drafts) {
  26. ?> 
  27. <div class="wrap">
  28. <?php if ($drafts) { ?>
  29.     <p><strong><?php _e('Your Drafts:') ?></strong> 
  30.     <?php
  31.     $i = 0;
  32.     foreach ($drafts as $draft) {
  33.         if (0 != $i)
  34.             echo ', ';
  35.         $draft->post_title = stripslashes($draft->post_title);
  36.         if ($draft->post_title == '')
  37.             $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
  38.         echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
  39.         ++$i;
  40.         }
  41.     ?> 
  42.     .</p> 
  43. <?php } ?>
  44.  
  45. <?php if ($other_drafts) { ?> 
  46.     <p><strong><?php _e('Other’s Drafts:') ?></strong> 
  47.     <?php
  48.     $i = 0;
  49.     foreach ($other_drafts as $draft) {
  50.         if (0 != $i)
  51.             echo ', ';
  52.         $draft->post_title = stripslashes($draft->post_title);
  53.         if ($draft->post_title == '')
  54.             $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
  55.         echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
  56.         ++$i;
  57.         }
  58.     ?> 
  59.     .</p> 
  60.  
  61. <?php } ?>
  62.  
  63. </div>
  64. <?php } ?>
  65.  
  66. <div class="wrap">
  67. <h2>
  68. <?php
  69. $what_to_show = 'posts';
  70. $posts_per_page = 15;
  71. $posts_per_archive_page = -1;
  72.  
  73. include(ABSPATH.'wp-blog-header.php');
  74.  
  75. if ( is_month() ) {
  76.     single_month_title(' ');
  77. } elseif ( is_search() ) {
  78.     printf(__('Search for “%s”'), wp_specialchars($_GET['s']) );
  79. } else {
  80.     if ( ! is_paged() || get_query_var('paged') == 1 )
  81.         _e('Last 15 Posts');
  82.     else
  83.         _e('Previous Posts');
  84. }
  85. ?>
  86. </h2>
  87.  
  88. <form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;"> 
  89.   <fieldset> 
  90.   <legend><?php _e('Search Posts…') ?></legend> 
  91.   <input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" /> 
  92.   <input type="submit" name="submit" value="<?php _e('Search') ?>"  /> 
  93.   </fieldset>
  94. </form>
  95.  
  96. <form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
  97.     <fieldset>
  98.     <legend><?php _e('Browse Month…') ?></legend>
  99.     <select name='m'>
  100.     <?php
  101.         $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts ORDER BY post_date DESC");
  102.         foreach ($arc_result as $arc_row) {            
  103.             $arc_year  = $arc_row->yyear;
  104.             $arc_month = $arc_row->mmonth;
  105.             
  106.             if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] )
  107.                 $default = 'selected="selected"';
  108.             else
  109.                 $default = null;
  110.             
  111.             echo "<option $default value=\"" . $arc_year.zeroise($arc_month, 2) . '">';
  112.             echo $month[zeroise($arc_month, 2)] . " $arc_year";
  113.             echo "</option>\n";
  114.         }
  115.     ?>
  116.     </select>
  117.         <input type="submit" name="submit" value="<?php _e('Show Month') ?>"  /> 
  118.     </fieldset>
  119. </form>
  120.  
  121. <br style="clear:both;" />
  122.  
  123. <?php
  124.  
  125. // define the columns to display, the syntax is 'internal name' => 'display name'
  126. $posts_columns = array(
  127.   'id'         => __('ID'),
  128.   'date'       => __('When'),
  129.   'title'      => __('Title'),
  130.   'categories' => __('Categories'),
  131.   'comments'   => __('Comments'),
  132.   'author'     => __('Author')
  133. );
  134. $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
  135.  
  136. // you can not edit these at the moment
  137. $posts_columns['control_view']   = '';
  138. $posts_columns['control_edit']   = '';
  139. $posts_columns['control_delete'] = '';
  140.  
  141. ?>
  142.  
  143. <table width="100%" cellpadding="3" cellspacing="3"> 
  144.     <tr>
  145.  
  146. <?php foreach($posts_columns as $column_display_name) { ?>
  147.     <th scope="col"><?php echo $column_display_name; ?></th>
  148. <?php } ?>
  149.  
  150.     </tr>
  151. <?php
  152. if ($posts) {
  153. $bgcolor = '';
  154. foreach ($posts as $post) { start_wp();
  155. $class = ('alternate' == $class) ? '' : 'alternate';
  156. ?> 
  157.     <tr class='<?php echo $class; ?>'>
  158.  
  159. <?php
  160.  
  161. foreach($posts_columns as $column_name=>$column_display_name) {
  162.  
  163.     switch($column_name) {
  164.     
  165.     case 'id':
  166.         ?>
  167.         <th scope="row"><?php echo $id ?></th>
  168.         <?php
  169.         break;
  170.  
  171.     case 'date':
  172.         ?>
  173.         <td><?php the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
  174.         <?php
  175.         break;
  176.     case 'title':
  177.         ?>
  178.         <td><?php the_title() ?>
  179.         <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
  180.         <?php
  181.         break;
  182.  
  183.     case 'categories':
  184.         ?>
  185.         <td><?php the_category(','); ?></td>
  186.         <?php
  187.         break;
  188.  
  189.     case 'comments':
  190.         ?>
  191.         <td><a href="edit.php?p=<?php echo $id ?>&c=1"> 
  192.       <?php comments_number(__('0'), __('1'), __('%')) ?> 
  193.       </a></td>
  194.         <?php
  195.         break;
  196.  
  197.     case 'author':
  198.         ?>
  199.         <td><?php the_author() ?></td>
  200.         <?php
  201.         break;
  202.  
  203.     case 'control_view':
  204.         ?>
  205.         <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
  206.         <?php
  207.         break;
  208.  
  209.     case 'control_edit':
  210.         ?>
  211.         <td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
  212.         <?php
  213.         break;
  214.  
  215.     case 'control_delete':
  216.         ?>
  217.         <td><?php if ( user_can_edit_post($user_ID,$post->ID) ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'OK\' to delete, \'Cancel\' to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "')\">" . __('Delete') . "</a>"; } ?></td>
  218.         <?php
  219.         break;
  220.  
  221.     default:
  222.         ?>
  223.         <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
  224.         <?php
  225.         break;
  226.     }
  227. }
  228. ?>
  229.     </tr> 
  230. <?php
  231. }
  232. } else {
  233. ?>
  234.   <tr style='background-color: <?php echo $bgcolor; ?>'> 
  235.     <td colspan="8"><?php _e('No posts found.') ?></td> 
  236.   </tr> 
  237. <?php
  238. } // end if ($posts)
  239. ?> 
  240. </table> 
  241.  
  242. <div class="navigation">
  243. <div class="alignleft"><?php next_posts_link(__('« Previous Entries')) ?></div>
  244. <div class="alignright"><?php previous_posts_link(__('Next Entries »')) ?></div>
  245. </div>
  246.  
  247. <?php
  248. if ( 1 == count($posts) ) {
  249.  
  250.     $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
  251.     if ($comments) {
  252.     ?> 
  253. <h3><?php _e('Comments') ?></h3> 
  254. <ol id="comments"> 
  255. <?php
  256. foreach ($comments as $comment) {
  257. $comment_status = wp_get_comment_status($comment->comment_ID);
  258. ?> 
  259.  
  260. <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?> >
  261.   <?php comment_date('Y-n-j') ?> 
  262.   @
  263.   <?php comment_time('g:m:s a') ?> 
  264.   <?php 
  265.             if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
  266.                 echo "[ <a href=\"post.php?action=editcomment&comment=".$comment->comment_ID."\">" .  __('Edit') . "</a>";
  267.                 echo " - <a href=\"post.php?action=deletecomment&p=".$post->ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";
  268.                 if ( ('none' != $comment_status) && ($user_level >= 3) ) {
  269.                     if ('approved' == wp_get_comment_status($comment->comment_ID)) {
  270.                         echo " - <a href=\"post.php?action=unapprovecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";
  271.                     } else {
  272.                         echo " - <a href=\"post.php?action=approvecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Approve') . "</a> ";
  273.                     }
  274.                 }
  275.                 echo "]";
  276.             } // end if any comments to show
  277.             ?> 
  278.   <br /> 
  279.   <strong> 
  280.   <?php comment_author() ?> 
  281.   (
  282.   <?php comment_author_email_link() ?> 
  283.   /
  284.   <?php comment_author_url_link() ?> 
  285.   )</strong> (IP:
  286.   <?php comment_author_IP() ?> 
  287.   )
  288.   <?php comment_text() ?> 
  289.  
  290. </li> 
  291. <!-- /comment --> 
  292. <?php //end of the loop, don't delete
  293.         } // end foreach
  294.     echo '</ol>';
  295.     }//end if comments
  296.     ?>
  297. <?php } ?> 
  298. </div> 
  299. <?php 
  300.  include('admin-footer.php');
  301. ?> 
  302.